/*
ID:luongho3
LANG:JAVA
TASK:sprime
 */
package usaco.training.chap1.sec5;

import java.io.File;
import java.io.PrintStream;
import java.util.Scanner;

public class sprime {

	static int N;
	static int[] n1 = {2,3,5,7};
	static int[] n2 = {1,3,7,9};
	
	public static void main(String[] args) throws Exception {
		Scanner scanner = new Scanner(new File("sprime.in"));
		PrintStream ps = new PrintStream(new File("sprime.out"));
		System.setOut(ps);
		N = scanner.nextInt();
		for (int i=0;i<4;++i) {
			int num = n1[i];
			dfs(1,num);
		}
	}

	private static void dfs(int n, int num) {
		if (n == N) {
			System.out.println(num);
		}
		else {
			for (int i=0;i<4;++i) {
				if (prime(num * 10 + n2[i])) {
					dfs(n+1,num * 10 + n2[i]);
				}
			}
		}
	}

	private static boolean prime(int n) {
		if (n == 2 || n == 3 || n == 5 || n == 7) {
			return true;
		}
		int i = 2;
		while (i * i <= n) {
			if (n % i == 0) {
				return false;
			}
			else {
				++i;
			}
		}
		return true;
	}
	
}
